<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AppendRulesToTariffTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('tariff', function (Blueprint $table) {
            //
            $table->enum('rules', [0, 1])->default(0)->index()->comment('资费类型：0-滴滴模式，1-出租车模式');
            $table->json('starting_price')->comment('起步价');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        if (Schema::hasColumns('tariff', ['rules', 'starting_price'])) {
            Schema::table('tariff', function (Blueprint $table) {
                $table->dropColumn(['rules', 'starting_price']);
            });
        }
    }
}
